﻿using System;
using System.Collections.Generic;
using System.Text;
using SyncCommon;
using System.Text.RegularExpressions;
using System.IO;

namespace SyncWebSite
{
    public class SyncGoufang : SyncHouseBase
    {
        private Dictionary<string, string> loginCookies = new Dictionary<string, string>();
        private List<string> retImages = new List<string>();
        private List<string> retthumbImages = new List<string>();
        private string targetID;
        private string CityID;
        private string CityShortName;
        private Encoding outEncoding = Encoding.GetEncoding("GB2312");
        private Encoding inputEncoding = Encoding.UTF8;
        private string ZoneID;
        private string StreetID;
        private string HouseID;
        private string EstateID = "";
        private string EstatePY = "";
        private string viewState = "";
        private string eventValidation = "";
        public SyncGoufang(string user, string password)
            : base(user, password)
        {

        }


        #region SyncHouseBase
        public override bool CheckLogin()
        {
            WebRequest request = new WebRequest("http://sh.goufang.com/agentsys/login.aspx", FormType.FormUrlEncode, outEncoding, outEncoding);
            request.Cookies = loginCookies;
            request.AllowRedirect = false;
            request.AddContent("txtUserid", UserName);
            request.AddContent("txtPwd", Password);
            request.AddContent("x", "15");
            request.AddContent("y", "14");
            

            string status = request.SendWaitString();

            if (!string.IsNullOrEmpty(request.TransferLocation))
            {
                request = new WebRequest("http://sh.goufang.com"+request.TransferLocation);
                request.ReturnEncoding = outEncoding;
                request.Cookies = loginCookies;
                status = request.GetResouceStr();
            }

            if (status.Contains("我的管理后台"))
            {
                return true;
            }
            return false;
        }

        public override bool AddSaleHouse(HouseInfo info, ref string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            string error = "";
            try
            {
                if (!CheckLogin())
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登录失败");
                    return false;
                }
                else
                {
                    string errorInfor = "";
                    if (!CommonCheck(info, true, ref errorInfor))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, errorInfor);
                        return false;
                    }
                    if (!CheckPassIdentify(true))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "没有通过身份验证，不能发布消息");
                        return false;
                    }

                    if (!MapEstateID(info))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "找不到该小区:" + info.Estate);
                        return false;
                    }
                    SyncImage(info);
                    WebRequest request = new WebRequest("http://sh.goufang.com/gl/fbcs.aspx", FormType.FormUrlEncode, outEncoding, outEncoding);
                    request.Cookies = loginCookies;
                    request.Cookies["gf_sid"] = "o2IIWK";
                    request.Cookies["_gf_city_id"] = "sh";
                    request.AddContent("__EVENTVALIDATION",eventValidation);
                    request.AddContent("__VIEWSTATE", viewState);
                    
                    FillPostData(info, request);
                    request.AddContent("txt_inputprice", info.Price);

                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("editInfo.aspx") && ret.Contains(HouseID))
                    {
                        targetID = HouseID;
                        UpdateCurrentStatus(StandardProgress.Sucess, GetImageError(info), HouseID, string.Format("http://sh.goufang.com/ershoufang-{0}.html", HouseID));
                        return true;
                    }
                    else
                    {
                        //<script language='javascript'>alert('服务器正忙，请稍后操作!');
                        //Regex reg = new Regex("<script language='javascript'>alert\\(\\'(?<message>.*?)\\'");
                        Regex reg = new Regex(@"<script( language='javascript')?>alert\('(?<message>.*?)'\)");
                        if (reg.IsMatch(ret))
                        {
                            error = reg.Match(ret).Groups["message"].Value;
                        }
                        else
                        {
                            error = "信息提交失败";
                        }
                    }
                }
            }
            catch (System.Net.WebException exp)
            {
                error = WebError;
            }
            catch (Exception exp)
            {
                LogCenter.Log("购房者网信息提交出错", exp);
                error = exp.Message;
            }
            UpdateCurrentStatus(StandardProgress.Failed, error);
            return false;
        }

        private void FillPostData(HouseInfo info, WebRequest request)
        {
            request.AddContent("ddl_Area", info.LocalDistrict);
            request.AddContent("ddl_buildyear", info.Age);
            request.AddContent("ddl_floortype", "1");
            request.AddContent("ddl_houselayout1", info.Room);
            request.AddContent("ddl_houselayout2", info.Hall);
            request.AddContent("ddl_houselayout3", info.WashRoom);
            request.AddContent("ddl_houselayout4", "");
            request.AddContent("ddl_property", "商品房");
            request.AddContent("FCKeditor1", info.Description);
            request.AddContent("hd_averageprice", "0");

            //小区ID 匹配。待处理
            request.AddContent("hd_xqid", EstateID);


            request.AddContent("hd_xqname", info.Estate);
            request.AddContent("hidd_square", info.LocalDiduan);
            request.AddContent("img_btn_fb.x", "53");
            request.AddContent("img_btn_fb.y", "5");

            if (retImages.Count > 0)
            {
                request.AddContent("inp_snt_autoid", "");
                request.AddContent("inp_snt_count", retImages.Count.ToString());
                request.AddContent("inp_snt_id", "100" + retImages.Count.ToString());

                request.AddContent("inp_hidd_sntp_swzt", "1");
                request.AddContent("inp_hidd_sntp_swzt_url", retImages[0]);
                for (int index = 0; index < retImages.Count; index++)
                {
                    request.AddContent("inp_hidd_xqhx_type100"+index.ToString(), "1");
                    request.AddContent("inp_hidd_xqhx_yl100" + index.ToString(), "");
                }
                
            }
            else
            {
                request.AddContent("inp_snt_autoid", "");
                request.AddContent("inp_snt_count", "0");
                request.AddContent("inp_snt_id", "1000");

                request.AddContent("inp_hidd_sntp_swzt", "");
                request.AddContent("inp_hidd_sntp_swzt_url", "");

            }
            request.AddContent("inp_hidd_sntp_swzt", "1000");
            request.AddContent("inp_hidd_sntp_swzt", "1000");
            request.AddContent("inp_houseid", HouseID);
            request.AddContent("inp_hxt_count", "0");
            request.AddContent("inp_hxt_id", "1");
            request.AddContent("inp_hxt_id", "2000");
         
            request.AddContent("inp_sntp_swzt", "1000");
            request.AddContent("inp_xqt_count", "0");
            request.AddContent("inp_xy", "");
            request.AddContent("rbl_cx", GetToward(info.Toward));
            request.AddContent("rbl_fwlx", GetHouseType(info));
            request.AddContent("hd_xqpy", "GLMY");
            request.AddContent("rbl_zx", GetDecoration(info));
            request.AddContent("txt_address", info.LocalAddress);
            request.AddContent("txt_areaname", info.Estate);
            request.AddContent("txt_bt", info.Title);
            request.AddContent("txt_floor1", info.CurrentFloor);
            request.AddContent("txt_fzmj", info.Area);
           
            request.AddContent("txt_totalfloors", info.Floors);
            request.AddContent("txt_zbh", "");
        }

        public override bool AddRentHouse(HouseInfo info, ref string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            string error = "";
            try
            {
                if (!CheckLogin())
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登录失败");
                    return false;
                }
                else
                {
                    string errorInfor = "";
                    if (!CommonCheck(info, false, ref errorInfor))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, errorInfor);
                        return false;
                    }
                    if (!CheckPassIdentify(false))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "没有通过身份验证，不能发布消息");
                        return false;
                    }

                    if (!MapEstateID(info))
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "找不到该小区:" + info.Estate);
                        return false;
                    }
                    SyncImage(info);
                    WebRequest request = new WebRequest("http://sh.goufang.com/gl/fbcz.aspx", FormType.FormUrlEncode, outEncoding, outEncoding);
                    request.Cookies = loginCookies;
                    request.AddContent("__EVENTVALIDATION", eventValidation);
                    request.AddContent("__VIEWSTATE", viewState);
                    FillPostData(info, request);
                    request.AddContent("txt_inputprice", info.MonthPrice);
                    request.AddContent("rbl_fzfs", GetPayment(info));
                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("editZFInfo.aspx") && ret.Contains(HouseID))
                    {
                        targetID = HouseID;
                        UpdateCurrentStatus(StandardProgress.Sucess, GetImageError(info), HouseID, string.Format("http://sh.goufang.com/zufang-{0}.html", HouseID));
                        return true;
                    }
                    else
                    {
                        //<script language='javascript'>alert('服务器正忙，请稍后操作!');
                        Regex reg = new Regex(@"<script( language='javascript')?>alert\('(?<message>.*?)'\)");
                        if (reg.IsMatch(ret))
                        {
                            error = reg.Match(ret).Groups["message"].Value;
                        }
                        else
                        {
                            error = "信息提交失败";
                        }
                    }
                }
            }
            catch (System.Net.WebException exp)
            {
                error = WebError;
            }
            catch (Exception exp)
            {
                LogCenter.Log("购房者网信息提交出错", exp);
                error = exp.Message;
            }
            UpdateCurrentStatus(StandardProgress.Failed, error);
            return false;
        }

        public override bool DeleteRentHouse(HouseInfo info, string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            try
            {
                if (CheckLogin())
                {

                    WebRequest request = InnerDelete(targetID, false);
                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("成功"))
                    {
                        UpdateCurrentStatus(StandardProgress.Sucess, "");
                        return true;
                    }
                    else
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "删除失败。");
                        return false;
                    }
                }
                else
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登陆失败");
                    return false;
                }
            }
            catch (System.Net.WebException exp)
            {
                UpdateCurrentStatus(StandardProgress.Failed, WebError);
                return false;
            }
        }

        public override bool DeleteSaleHouse(HouseInfo info, string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            try
            {
                if (CheckLogin())
                {

                    WebRequest request = InnerDelete(targetID, true);
                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("成功"))
                    {
                        UpdateCurrentStatus(StandardProgress.Sucess, "");
                        return true;
                    }
                    else
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "删除失败。");
                        return false;
                    }
                }
                else
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登陆失败");
                    return false;
                }
            }
            catch (System.Net.WebException exp)
            {
                UpdateCurrentStatus(StandardProgress.Failed, WebError);
                return false;
            }
        }

        private WebRequest InnerDelete(string targetID,bool isSale)
        {
            WebRequest request;
            if (isSale)
            {
                request = new WebRequest("http://sh.goufang.com/gl/eshouse/ajaxPost.aspx", FormType.FormUrlEncode);
            }
            else
            {
                request = new WebRequest("http://sh.goufang.com/gl/zfhouse/ajaxPost.aspx", FormType.FormUrlEncode);
            }
            request.Cookies = loginCookies;
            request.ReturnEncoding = outEncoding;
            request.AddContent("ot", "insertstock");
            request.AddContent("houseid", targetID);
            request.AddContent("pc1", "0");
            request.AddContent("pc2", "0");

            request.AddContent("htype", "");
            request.AddContent("isref", "false");

            request.AddContent("st", "keywords");
            request.AddContent("keyword", "");
            request.AddContent("page", "1");
            request.AddContent("horder", "h.houseid:1");
            request.AddContent("itemid", "2");
            return request;
        }

        public override bool RefreshRentHouse(HouseInfo info, string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            try
            {
                if (CheckLogin())
                {
                    WebRequest request = InnerRefresh(targetID, false);
                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("您成功刷新"))
                    {
                        UpdateCurrentStatus(StandardProgress.Sucess, "");
                        return true;
                    }
                    else
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "刷新失败。请检查购房币是否不足。");
                        return false;
                    }
                }
                else
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登陆失败");
                    return false;
                }
            }
            catch (System.Net.WebException exp)
            {
                UpdateCurrentStatus(StandardProgress.Failed, WebError);
                return false;
            }
        }
        public override bool RefreshSaleHouse(HouseInfo info, string targetID)
        {
            UpdateCurrentStatus(StandardProgress.InitalData);
            try
            {
                if (CheckLogin())
                {
                    WebRequest request = InnerRefresh(targetID, true);
                    UpdateCurrentStatus(StandardProgress.PosData);
                    string ret = request.SendWaitString();
                    if (ret.Contains("您成功刷新"))
                    {
                        UpdateCurrentStatus(StandardProgress.Sucess, "");
                        return true;
                    }
                    else
                    {
                        UpdateCurrentStatus(StandardProgress.Failed, "刷新失败。请检查购房币是否不足。");
                        return false;
                    }
                }
                else
                {
                    UpdateCurrentStatus(StandardProgress.Failed, "登陆失败");
                    return false;
                }
            }
            catch (System.Net.WebException exp)
            {
                UpdateCurrentStatus(StandardProgress.Failed, WebError);
                return false;
            }

        }

        private WebRequest InnerRefresh(string targetID,bool isSale)
        {
            WebRequest request;
            if (isSale)
            {
                request = new WebRequest("http://sh.goufang.com/gl/eshouse/ajaxPost.aspx", FormType.FormUrlEncode);
            }
            else
            {
                request = new WebRequest("http://sh.goufang.com/gl/zfhouse/ajaxPost.aspx", FormType.FormUrlEncode);
            }
            request.Cookies = loginCookies;
            request.ReturnEncoding = outEncoding;
            request.AddContent("ot", "resethouse");
            request.AddContent("houseid", targetID);
            request.AddContent("pc1", "0");
            request.AddContent("pc2", "0");

            request.AddContent("htype", "");
            request.AddContent("isref", "false");

            request.AddContent("st", "keywords");
            request.AddContent("keyword", "");
            request.AddContent("page", "1");
            request.AddContent("horder", "h.houseid:1");
            request.AddContent("itemid", "2");
            return request;
        }

        public void SyncImages()
        {
            
        }
        public void SyncImage(HouseInfo info)
        {
            retImages.Clear();
            errorImage = 0;
            if (info.Images != null && info.Images.Length > 0)
            {
                foreach (string url in info.Images)
                {
                    try
                    {
                        WebRequest request = new WebRequest(url);
                        Stream stream = request.GetResouce();
                        string name = url.Substring(url.LastIndexOf('/') + 1);

                        request = new WebRequest("http://sh.goufang.com/gl/HXUpload.aspx?houseid=" + HouseID, FormType.MultiPart);
                        request.ReturnEncoding = outEncoding;
                        request.Cookies = loginCookies;
                        request.AddContent("__VIEWSTATE", "/wEPDwULLTEyMjYwMzgwNjYPZBYCZg8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YRYCAgIPFgIeCG9uY2hhbmdlBQ9yZXR1cm4gaHh0X3lsKClkZNG5O756mJIkypoWnT0Cp9xA3DnX");
                        request.AddContent("inp_xqhxid", "1");
                        request.AddContent("__EVENTVALIDATION", "/wEWAgKE0L/NCQKZybeoDuXVm3P21fPCLkEcF6OPwkBybFQ3");
                        request.AddFile(name, "file1", stream);
                        string k = request.SendWaitString();

                        //uploadsucces('1000','http://sh.data.goufang.com/House/photos/00657265/842112428894640.gif')
                        Regex reg = new Regex("uploadsucces\\(\\'\\d*?\\',\\'(?<url>.*?)\\'");
                        Match ma = reg.Match(k);
                        if (ma.Success)
                        {
                            retImages.Add(ma.Groups["url"].Value);
                        }
                        else
                        {
                            //reg = new Regex("<script>alert\\(\\'(?<message>.*?)\\'\\)");
                            //string error = "购房者网站,图片未上传成功!合法码:" + info.HefaCode;
                            //ma = reg.Match(k);
                            //if (ma.Success)
                            //{
                            //    error = "购房者网站。图片上传:" + ma.Groups["message"];
                            //}
                            //LogCenter.LogMessage(error);
                            errorImage++;
                        }
                    }
                    catch
                    {
                        errorImage++;
                    }
                }
            }

        }


        public bool CheckPassIdentify(bool isSale)
        {
            WebRequest request = null;
            if (isSale)
            {
                request = new WebRequest("http://sh.goufang.com/gl/fbcs.aspx");
            }
            else
            {
                request = new WebRequest("http://sh.goufang.com/gl/fbcz.aspx");
            }

            //"/gl/pim/identityManage.aspx"
            request.Cookies = loginCookies;
            request.AllowRedirect = false;
            string ret = request.GetResouceStr();
            if (!string.IsNullOrEmpty(request.TransferLocation))
            {
                return false;
            }
            else
            {
                Regex reg = new Regex("var houseid=\"(?<houseid>.*?)\"");
                Match ma = reg.Match(ret);
                if (ma.Success)
                {
                    HouseID = ma.Groups["houseid"].Value;
                }
                viewState = HtmlHelper.GetViewState(ret);
                eventValidation = HtmlHelper.GetEventValidation(ret);
            }
            return true;
        }

        public bool MapEstateID(HouseInfo info)
        {
            WebRequest request = new WebRequest(string.Format("http://sh.goufang.com/gl/ajax.aspx?divid=displayXqlist&key={0}&type=es", HtmlHelper.Escape(info.Estate)));
            
            request.Cookies = loginCookies;
            request.ReturnEncoding = outEncoding;
            string ret = request.GetResouceStr();
            //"xqclick('3102','玉兰香苑','YLXY','17781','浦东区','浦东区张江地区','')
            Regex reg = new Regex("xqclick\\(\\'(?<ids>.*?)\\',");
            Match ma = reg.Match(ret);
            if (ma.Success)
            {
                EstateID = ma.Groups["ids"].Value;
                return true;
            }
            return false;
        }

        public string GetHouseType(HouseInfo info)
        { 
            //当前平房=1,普通住宅=2,商住两用=3,公寓=4,别墅=5,其他=6
            //目标(汉字) 住宅,写字间,公寓,商铺,商住两用,仓库厂房,别墅,洋房,其他
            switch (info.HouseType)
            { 
                case "1":
                case "2":
                    return "住宅";
                case "3":
                    return "商住两用";
                case "4":
                    return "公寓";
                case "5":
                    return "别墅";
                case "6":
                    return "其他";
            }
            return "住宅";
        }

        private string GetDecoration(HouseInfo info)
        {
            //当前 1:毛胚 2:简装 3:精装 4:豪装
            //目标 毛坯	初装修 精装 豪装
            switch (info.Decoration)
            {
                case "1":
                    return "毛坯";
                case "2":
                    return "初装修";
                case "3":
                    return "精装";
                case "4":
                    return "豪装";
                default:
                    return "精装";
            }
        }

        public string GetToward(string toward)
        {
            //当前 1:东 2:南 3:西 4:北 5:南北 6:东西 7:东南 8:西南 9:东北 10:西北 11:其他
            //目标(汉字) 东	南	西	北	南北	双南	东西	东南	东北 	西南	 西北
            if (toward == "1")
            {
                return "东";
            }
            if (toward == "2")
            {
                return "南";
            }
            if (toward == "3")
            {
                return "西";
            }
            if (toward == "4")
            {
                return "北";
            }

            if (toward == "5")
            {
                return "南北";
            }
            if (toward == "6")
            {
                return "东西";
            }
            if (toward == "7")
            {
                return "东南";
            }
            if (toward == "8")
            {
                return "西南";
            }

            if (toward == "9")
            {
                return "东北";
            }
            if (toward == "10")
            {
                return "西北";
            }
            return "南";
        }
        public string GetPayment(HouseInfo info)
        {
            //当前 1:付一押一 2:付二押一 3:付三押一 4:付六押一
            //文字 日付	周付	月付	季付	半年付	年付
            switch (info.PayType)
            {
                case "1":
                    return "月付";
                case "2":
                    return "月付";
                case "3":
                    return "季付";
                case "4":
                    return "半年付";
            }
            return "月付";
        }
        #endregion

        #region 编辑功能
        public override bool OpenEidt(WebBrowserOp op, HouseInfo info)
        {
            try
            {
                if (CheckLogin())
                {
                    if (info.TradeType == TradeType.Sale)
                    {
                        string post = "http://sh.goufang.com/gl/fbcs.aspx";
                        foreach (KeyValuePair<string, string> k in loginCookies)
                        {
                            WebBrowserOp.InternetSetCookie(post, k.Key, k.Value);
                        }
                        op.HouseInformation = info;
                        op.Navigate(post);
                        op.Completed += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(op_Sale_Completed);
                    }
                    else
                    {
                        string post = "http://sh.goufang.com/gl/fbcz.aspx";
                        foreach (KeyValuePair<string, string> k in loginCookies)
                        {
                            WebBrowserOp.InternetSetCookie(post, k.Key, k.Value);
                        }
                        op.HouseInformation = info;
                        op.Navigate(post);
                        op.Completed += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(op_Rent_Completed);
                    }

                }
                else
                {
                    return false;
                }
            }
            catch
            {
                op.Navigate("http://sh.goufang.com/");
            }
            return true;
        }
        void op_Sale_Completed(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowserOp cl = sender as WebBrowserOp;
            HouseInfo info = cl.HouseInformation;

            cl.SetValueByID("txt_areaname", info.Estate);
            cl.SelectByID_Value("ddl_Area", info.LocalDistrict);
            
            cl.SetValueByID("txt_address", info.LocalAddress);

            cl.SetValueByName("txt_fzmj", info.Area);

            cl.SelectByID_Value("ddl_houselayout1", info.Room);
            cl.SelectByID_Value("ddl_houselayout2", info.Hall);
            cl.SelectByID_Value("ddl_houselayout3", info.WashRoom);

            cl.SetValueByID("txt_inputprice", info.Price);

            cl.SetValueByID("txt_floor1", info.CurrentFloor);
            cl.SetValueByID("txt_totalfloors", info.Floors);

            cl.SelectByID_Value("ddl_buildyear", info.Age);

            cl.CheckByName_Value("rbl_fwlx", GetHouseType(info), true);

            cl.CheckByName_Value("rbl_cx",  GetToward(info.Toward), true);

            cl.CheckByName_Value("rbl_zx",  GetDecoration(info), true);

            cl.SetValueByID("txt_bt", info.Title);
            cl.SetCKEditorHtml("xhe0_iframe", info.Description);

        }
        void op_Rent_Completed(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowserOp cl = sender as WebBrowserOp;
            HouseInfo info = cl.HouseInformation;

            cl.SetValueByID("txt_areaname", info.Estate);
            cl.SelectByID_Value("ddl_Area", info.LocalDistrict);

            cl.SetValueByID("txt_address", info.LocalAddress);

            cl.SetValueByName("txt_fzmj", info.Area);

            cl.SelectByID_Value("ddl_houselayout1", info.Room);
            cl.SelectByID_Value("ddl_houselayout2", info.Hall);
            cl.SelectByID_Value("ddl_houselayout3", info.WashRoom);

            cl.SetValueByID("txt_inputprice", info.MonthPrice);
            cl.CheckByName_Value("rbl_fzfs", GetPayment(info),true);

            cl.SetValueByID("txt_floor1", info.CurrentFloor);
            cl.SetValueByID("txt_totalfloors", info.Floors);

            cl.SelectByID_Value("ddl_buildyear", info.Age);

            cl.CheckByName_Value("rbl_fwlx", GetHouseType(info), true);

            cl.CheckByName_Value("rbl_cx", GetToward(info.Toward), true);

            cl.CheckByName_Value("rbl_zx", GetDecoration(info), true);

            cl.SetValueByID("txt_bt", info.Title);
            cl.SetCKEditorHtml("xhe0_iframe", info.Description);

        }
        #endregion
    }
}
